package jh.com.jhappbf.weight.query;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import androidx.fragment.app.Fragment;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import jh.com.jhappbf.R;
import jh.com.jhappbf.weight.collect.InnerCollectActivity;
import jh.com.jhappbf.work.WorkSettingActivity;

/**
 * @author : wwh
 * e-mail  : 953889276@qq.com
 * time    : 2019-7-6 8:49:18
 * desc    :
 */
public class InnerQueryMain extends Fragment {

    @BindView(R.id.inner_query_img)
    ImageView innerQueryImg;
    @BindView(R.id.inner_query_layout)
    RelativeLayout innerQueryLayout;
    @BindView(R.id.inner_collect_img)
    ImageView innerCollectImg;
    @BindView(R.id.inner_collect_layout)
    RelativeLayout innerCollectLayout;
    @BindView(R.id.inner_collect_img2)
    ImageView innerCollectImg2;
    @BindView(R.id.inner_collect_layout2)
    RelativeLayout innerCollectLayout2;
    @BindView(R.id.inner_setting_img)
    ImageView innerSettingImg;
    @BindView(R.id.inner_setting_layout)
    RelativeLayout innerSettingLayout;

    private String mStartTime = "";
    private String mStartDate = "";
    private String mEndTime = "";
    private String mEndDate = "";

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        View v = inflater.inflate(R.layout.activity_inner_query_main, null);
        ButterKnife.bind(this, v);
        return v;
    }


    @OnClick({R.id.inner_query_img, R.id.inner_query_layout, R.id.inner_collect_img, R.id.inner_collect_layout, R.id.inner_setting_img, R.id.inner_setting_layout, R.id.inner_collect_img2, R.id.inner_collect_layout2})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.inner_query_img:
            case R.id.inner_query_layout:
                Intent intent = new Intent(getActivity(), InnerQueryActivity.class);
                intent.putExtra("startTime",mStartTime);
                intent.putExtra("startDate",mStartDate);
                intent.putExtra("endTime",mEndTime);
                intent.putExtra("endDate",mEndDate);
                startActivity(intent);
                break;
            case R.id.inner_collect_img:
            case R.id.inner_collect_layout:
                Intent intent2 = new Intent(getActivity(), InnerCollectActivity.class);
                intent2.putExtra("flag","buy");
                intent2.putExtra("startTime",mStartTime);
                intent2.putExtra("startDate",mStartDate);
                intent2.putExtra("endTime",mEndTime);
                intent2.putExtra("endDate",mEndDate);
                startActivity(intent2);
                break;
            case R.id.inner_collect_img2:
            case R.id.inner_collect_layout2:
                Intent intent3 = new Intent(getActivity(), InnerCollectActivity.class);
                intent3.putExtra("flag","out");
                intent3.putExtra("startTime",mStartTime);
                intent3.putExtra("startDate",mStartDate);
                intent3.putExtra("endTime",mEndTime);
                intent3.putExtra("endDate",mEndDate);
                startActivity(intent3);
                break;
            case R.id.inner_setting_img:
            case R.id.inner_setting_layout:
                Intent intent4 = new Intent(getActivity(), WorkSettingActivity.class);
                startActivityForResult(intent4,0x0001);
                break;
            default:
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (data != null) {
            mStartDate = data.getStringExtra("startDate");
            mStartTime = data.getStringExtra("startTime");
            mEndDate = data.getStringExtra("endDate");
            mEndTime = data.getStringExtra("endTime");
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
}
